<template>
  <svg :class="getClassName"
       :width="width"
       :height="height"
       aria-hidden="true"
       v-on="$listeners">
    <use :xlink:href="getIconName" />
  </svg>
</template>

<script>
export default {
  name: 'IconSvg',
  props: {
    iconName: {
      type: String,
      required: true
    },
    className: {
      type: String,
      default: ''
    },
    width: {
      type: String
    },
    height: {
      type: String
    }
  },
  computed: {
    getIconName () {
      return `#icon-${this.iconName}`
    },
    getClassName () {
      if (this.className) {
        return 'icon-svg ' + this.className
      } else {
        return 'icon-svg'
      }
    }
  }
}
</script>

<style scoped>
  .icon-svg {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    fill: currentColor;
    overflow: hidden;
  }
</style>
